#define CL_TARGET_OPENCL_VERSION 300

#include "pch.h"
#include "introp.h"
#include <CL/cl.h>
#include "pch.h"
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>

int GetPlatforms(void* ptr, int* count)
{
	cl_int CL_err = CL_SUCCESS;
	cl_uint numPlatforms = 0;
	if (ptr == NULL)
	{
		CL_err = clGetPlatformIDs(0, NULL, &numPlatforms);
	}
	else
	{
		CL_err = clGetPlatformIDs(*count, (cl_platform_id*)ptr, &numPlatforms);
	}
	*count = numPlatforms;
	if (CL_err == CL_SUCCESS)
		return 0;
	else
		return CL_err;
};

int convertToStringEx(const char* filename, std::string& s)
{
	size_t size;
	char* str;
	std::fstream f(filename, (std::fstream::in | std::fstream::binary));
	if (f.is_open())
	{
		size_t fileSize;
		f.seekg(0, std::fstream::end);
		size = fileSize = (size_t)f.tellg();
		f.seekg(0, std::fstream::beg);
		str = new char[size + 1];
		if (!str)
		{
			f.close();
			return NULL;
		}
		f.read(str, fileSize);
		f.close();
		str[size] = '\0';
		s = str;
		delete[] str;
		return 0;
	}
	printf("Error: Failed to open file %s\n", filename);
	return 1;
}